<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../Public/js/jquery-1.11.1.min.js"></script>
</head>
<body>
<!--邮箱-->
<input id="reg" value="[a-z]\w{1,17}@[-a-z0-9]+(?:\.[-a-z0-9]+)+" type="hidden">
<div style="margin-left:500px;">邮件地址：<input id="inp"><span id="span"></span></div>

<!--手机号-->
<input id="reg1" value="1(3|4|5|7|8)\d{9}" type="hidden">
<div style="margin-left:500px;">手机号：<input id="inp1"><span id="span1"></span></div>

<!--绵阳电话号-->
<input id="reg2" value="0816([1-9]){1}\d{7}" type="hidden">
<div style="margin-left:500px;">绵阳电话号：<input id="inp2"><span id="span2"></span></div>

<!--合法的数字-->
<input id="reg3" value="\d+(?:\.\d+)?(?:[/]\d+(?:\.\d+)?)?(?<![/]0)" type="hidden">
<div style="margin-left:500px;">合法的数字：<input id="inp3"><span id="span3"></span></div>

<!--字符串-->
<div style="margin-left:500px;"><input id="inp4" value="event=&operator=17&max=50&sort=remark&order=asc" style="width: 400px"><button id="b">输出</button></div>

<!--获取标签-->
<div style="margin-left:500px;"><input id="inp5" value="<div>123</div>312<span>qweasd</span><a>asdw</a><button>asdawd</button>" style="width: 600px"><button id="v">获取标签</button></div>

<!--获取中文数字-->
<form style="margin-left: 500px">
    <span>
        数字转化：
        <input type="number" name="xiao" id="inp6"/>
        <input type="text" name="da" readonly="true" size="30" style="border-style:dotted; border-color:#9900FF;"/>
    </span>
</form>

<!-- -&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->

<script>
    $('#inp').keyup(function (){
        $('#span').html(eval('/^'+$('#reg').val()+'$/').test($('#inp').val())?'合法':'错误');//邮箱
    });

    $('#inp1').keyup(function(){
        $('#span1').html(eval('/^'+$('#reg1').val()+'$/').test($('#inp1').val())?'合法':'错误');//手机号
    });

    $('#inp2').keyup(function(){
        $('#span2').html(eval('/^'+$('#reg2').val()+'$/').test($('#inp2').val())?'合法':'错误');//绵阳电话号
    });

    $('#inp3').keyup(function(){
        $('#span3').html(eval('/^'+$('#reg3').val()+'$/').test($('#inp3').val())?'合法':'错误');//合法的数字
    });

    $('#b').click(function(){
        var b =  /(([a-z]+){1})=(([0-9a-z]+)*)/g;
        var b1 = $('#inp4').val();
        var w="";
        w=b1.replace(b,function($0,$1,$2,$3){
            return $1+','+$3;
        });
//        console.log(w);
        var w1=/(([a-z]+){1}),(([0-9a-z]+)*)/g;
        while (w1.exec(w)){
            console.log(RegExp.lastMatch);//字符串
        }
    });

    $('#v').click(function(){
        var v1=/<(\w+)[^<>]*>/g;
        var v2=$('#inp5').val();
        while (v1.exec(v2)){
            console.log(RegExp.lastMatch);
        }<!--获取标签-->
    });


//    转换大小写
    $('#inp6').keyup(function(){
        var input=document.forms[0].elements['xiao'].value;
        var danwei=["","十","百","千","万","十","百","千","亿"];
        var inputvalue=parseInt(input);
        var l=input.length;
        var a=new Array(l);
        var b=new Array(l);
        var result="";
        for(var i=0;i<l;i++)
        {
            a[i]=input.substr(i,1);
            b[i]=getchinese(a[i]);
            result+=b[i]+danwei[l-i-1];
        }
        document.forms[0].elements['da'].value=result;
    });

    function getchinese(p)
    {
        var input=p;
        if(input=="0")
            return "零";
        else if(input=="1")
            return "一";
        else if(input=="2")
            return "二";
        else if(input=="3")
            return "三";
        else if(input=="4")
            return "四";
        else if(input=="5")
            return "五";
        else if(input=="6")
            return "六";
        else if(input=="7")
            return "七";
        else if(input=="8")
            return "八";
        else if(input=="9")
            return "九";
    }

</script>
</body>
</html>